﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using PGMHelper;

using WH = PGMHelper.WilsonHelper;

namespace CouplingBeamProject
{
    /// <summary>
    /// 全局变量
    /// </summary>
    static class GlobalVar
    {
        /// <summary>
        /// 剖分尺度
        /// </summary>
        public static double MeshDimension = 100;

        /// <summary>
        /// 混凝土弹性模量
        /// </summary>
        public static double ConcreteYoungsModulus = 3E4;

        /// <summary>
        /// 水平拉缝弹性模量
        /// </summary>
        public static double HorizontalSeamYoungsModulus = 300;

        /// <summary>
        /// 竖向拉缝弹性模量
        /// </summary>
        public static double VerticalSeamYoungsModulus  = 300;

        /// <summary>
        /// 混凝土泊松比
        /// </summary>
        public static double ConcretePossionRatio = 0.2;

        /// <summary>
        /// 水平拉缝泊松比
        /// </summary>
        public static double HPossionRatio = 0.2;

        /// <summary>
        /// 竖向拉缝泊松比
        /// </summary>
        public static double VPossionRatio = 0.2;

        /// <summary>
        /// 厚度
        /// </summary>
        public static double Thickness = 200;

        /// <summary>
        /// 顶点水平力
        /// </summary>
        public static double MaxLoad = 10000;

        /// <summary>
        /// 计算等效梁高的相对误差
        /// </summary>
        public static double GetEquilibrumBeamHeigthTol = 1E-2;

        /// <summary>
        /// 混凝土弹模放大倍数基数
        /// </summary>
        public static double ElasticModulusFactorBase = 50;

        /// <summary>
        /// 最大梁高系数
        /// </summary>
        public static double BeamHeightLimitRatio = 0.95;

        /// <summary>
        /// 考虑刚性隔板
        /// </summary>
        public static bool isRigidFloor = true;

        /// <summary>
        /// 中间梁最小跨度
        /// </summary>
        public static double BeamSpanMin = 1000;

        /// <summary>
        /// 中间梁最大跨度
        /// </summary>
        public static double BeamSpanMax = 8000;

        /// <summary>
        /// 中间梁跨度增量
        /// </summary>
        public static double BeamSpanDelta = 1000;

        /// <summary>
        /// 中间梁最小高度
        /// </summary>
        public static double BeamHeightMin = 400;

        /// <summary>
        /// 中间梁最大高度
        /// </summary>
        public static double BeamHeightMax = 1200;

        /// <summary>
        /// 中间梁高度增量
        /// </summary>
        public static double BeamHeightDelta = 200;

        ///// <summary>
        ///// 楼层最小高度
        ///// </summary>
        //public static double StoreyHeightMin = 2500;

        ///// <summary>
        ///// 楼层最大高度
        ///// </summary>
        //public static double StoreyHeightMax = 6000;

        ///// <summary>
        ///// 楼层高度增量
        ///// </summary>
        //public static double StoreyHeightDelta = 500;

        /// <summary>
        /// 左墙最小宽度
        /// </summary>
        public static double LeftWallWidthMin = 500;

        /// <summary>
        /// 左墙最大宽度
        /// </summary>
        public static double LeftWallWidthMax = 4500;

        /// <summary>
        /// 左墙宽度增量
        /// </summary>
        public static double LeftWallWidthDelta = 1000;

        /// <summary>
        /// 墙比例系数最小值（右墙宽/左墙宽）
        /// </summary>
        public static double WallRatioMin = 1.0;

        /// <summary>
        /// 墙比例系数最大值（右墙宽/左墙宽）
        /// </summary>
        public static double WallRatioMax = 6.0;

        /// <summary>
        /// 墙比例系数增量（右墙宽/左墙宽）
        /// </summary>
        public static double WallRatioDelta = 1.0;

        ///// <summary>
        ///// 楼层数
        ///// </summary>
        //public static int StoreyNum = 3;

        /// <summary>
        /// 构造函数
        /// </summary>
        public static void Initial()
        {
            var group = "Global";
            var fileName = WH.GetAssemblyDirectory() +  "\\CouplingBeamProj.ini";
            MeshDimension = Convert.ToDouble(WH.ReadINI(group, "MeshDimension", "100", fileName));
            ConcreteYoungsModulus = Convert.ToDouble(WH.ReadINI(group, "ConcreteYoungsModulus", "3E4", fileName));
            HorizontalSeamYoungsModulus = Convert.ToDouble(WH.ReadINI(group, "HorizontalSeamYoungsModulus ", "300", fileName));
            VerticalSeamYoungsModulus = Convert.ToDouble(WH.ReadINI(group, "VerticalSeamYoungsModulus", "300", fileName));
            ConcretePossionRatio = Convert.ToDouble(WH.ReadINI(group, "ConcretePossionRatio", "0.2", fileName));
            HPossionRatio = Convert.ToDouble(WH.ReadINI(group, "HPossionRatio", "0.2", fileName));
            VPossionRatio = Convert.ToDouble(WH.ReadINI(group, "VPossionRatio", "0.2", fileName));
            Thickness = Convert.ToDouble(WH.ReadINI(group, "Thickness", "200", fileName));
            GetEquilibrumBeamHeigthTol = Convert.ToDouble(WH.ReadINI(group, "GetEquilibrumBeamHeigthTol", "0.01", fileName));
            MaxLoad = Convert.ToDouble(WH.ReadINI(group, "MaxLoad", "10000", fileName));
            ElasticModulusFactorBase = Convert.ToDouble(WH.ReadINI(group, "ElasticModulusFactorBase", "50", fileName));
            BeamHeightLimitRatio = Convert.ToDouble(WH.ReadINI(group, "BeamHeightLimitRatio", "0.95", fileName));
            isRigidFloor = Convert.ToInt32(WH.ReadINI(group, "ConsiderRigidFloor", "1", fileName)) != 0;
            BeamSpanMin = Convert.ToDouble(WH.ReadINI(group, "BeamSpanMin", "1000", fileName));
            BeamSpanMax = Convert.ToDouble(WH.ReadINI(group, "BeamSpanMax", "8000", fileName));
            BeamSpanDelta = Convert.ToDouble(WH.ReadINI(group, "BeamSpanDelta", "1000", fileName));
            BeamHeightMin = Convert.ToDouble(WH.ReadINI(group, "BeamHeightMin", "400", fileName));
            BeamHeightMax = Convert.ToDouble(WH.ReadINI(group, "BeamHeightMax", "1200", fileName));
            BeamHeightDelta = Convert.ToDouble(WH.ReadINI(group, "BeamHeightDelta", "200", fileName));
            //StoreyHeightMin = Convert.ToDouble(WH.ReadINI(group, "StoreyHeightMin", "2500", fileName));
            //StoreyHeightMax = Convert.ToDouble(WH.ReadINI(group, "StoreyHeightMax", "6000", fileName));
            //StoreyHeightDelta = Convert.ToDouble(WH.ReadINI(group, "StoreyHeightDelta", "500", fileName));
            LeftWallWidthMin = Convert.ToDouble(WH.ReadINI(group, "LeftWallWidthMin ", "500", fileName));
            LeftWallWidthMax = Convert.ToDouble(WH.ReadINI(group, "LeftWallWidthMax", "4500", fileName));
            LeftWallWidthDelta = Convert.ToDouble(WH.ReadINI(group, "LeftWallWidthDelta", "1000", fileName));
            WallRatioMin = Convert.ToDouble(WH.ReadINI(group, "WallRatioMin", "1.0", fileName));
            WallRatioMax = Convert.ToDouble(WH.ReadINI(group, "WallRatioMax", "6.0", fileName));
            WallRatioDelta = Convert.ToDouble(WH.ReadINI(group, "WallRatioDelta", "1.0", fileName));
            //StoreyNum = Convert.ToInt32(WH.ReadINI(group, "StoreyNum", "3", fileName));
        }
    }
}
